<template>
  <div class="main">
    <view class="item">
      <view class="flex justifyBetween alignCenter">
        <view class="bold fz14">您的薪酬范围是</view>
      </view>

      <!-- 日期时间选择器 -->
      <picker-view @change="bindChange" class="picker-view" :value="salary" v-if="salaryRange.length">
        <picker-view-column>
          <view class="timeItem" :class="{active: index ==salary[0]}" v-for="(item,index) in salaryRange" :key="index">{{item.configValue}}</view>
        </picker-view-column>
      </picker-view>
    </view>

    <view class="next flex justifyFlexEnd">
      <uv-button @click="next" :customStyle="nextBtnStyle" text="下一步" shape="circle" color="linear-gradient(to right, rgba(178, 161, 255, 1), rgba(211, 167, 249, 1))"></uv-button>
    </view>
  </div>
</template>

<script setup lang="ts">
import useCounterStore from "@/stores/counter";
const counter = useCounterStore();
const { proxy } = getCurrentInstance();
let props = defineProps(["modelValue"]);
const emit = defineEmits(["update:modelValue", "fatherMethod"]);

const valueDate = computed({
  get() {
    return props.modelValue;
  },
  set(value) {
    emit("update:modelValue", value);
  },
});

let salary = ref([0]);

let inputStyle = ref({
  backgroundColor: "#F6F6F6",
  padding: "10px 10px",
});

let salaryRange = ref([]); //收入

let nextBtnStyle = ref({
  width: "100px",
  boxShadow: "0 2px 8px 2px rgba(182, 159, 254, 0.53)",
});

onMounted(() => {
  getinfo();
});

let next = () => {
  if (!valueDate.value.income)
    return proxy.$utils.showToast("请选择您的薪酬范围");
  emit("fatherMethod");
};

let bindChange = (e) => {
  let val = e.detail.value;
  valueDate.value.income = salaryRange.value[val[0]].configValue;
};

let getinfo = async (value) => {
  let data = await proxy.$apis.getOpenScreenMsg({
    configKey: "income_value",
  });
  salaryRange.value = data;
  console.log("收入", data);
};
</script>



<style lang="scss" scoped>
.picker-view {
  width: 100%;
  height: 150px;
  .timeItem {
    line-height: 34px;
    text-align: center;
  }
}
.next {
  margin-right: 10vw;
  margin-top: 10vw;
}
</style>
